import { alovaInstance } from '@/utils/http'

export interface LoginParams {
  username: string
  password: string
}
export interface LoginResult {
  token: string
}
export function login(data: LoginParams) {
  return alovaInstance.Post<LoginResult>('/auth/login', data)
}

export function logout() {
  return alovaInstance.Post('/auth/logout')
}

export interface UserInfo {
  id: number
  username: string
  nickname: string
  avatar: string
  codes: string[]
  roles: string[]
}
export function info() {
  return alovaInstance.Get<UserInfo>('/auth/info')
}
